﻿#include "GameHomePage.h"
#include <easyx.h>
#include <fstream>
gameState GameHomePage(bool& isRun) {
	cleardevice();  // 清空屏幕
	// 加载游戏首页背景图片
	BeginBatchDraw();
	std::ifstream file_check("assets/picture/homepage.png");
	if (file_check) {
		file_check.close(); // 关闭文件流后再加载图片
		loadimage(&bgimage, _T("assets/picture/homepage.png"), windowWidth, windowHeight, true);
		putimage(0, 0, &bgimage);
	}
	EndBatchDraw();
	// 处理用户输入
	while (true)
	{
		ExMessage msg = { 0 };

		peekmessage(&msg, EX_KEY);
		switch (msg.vkcode)
		{
		case 'A':
			AutoSound();
			return GAME_PLOTBG;  // 进入剧情介绍
		case 'B':
			AutoSound();
			return GAME_SETTING;  // 进入游戏设置
		case 'C':
			AutoSound();
			return GAME_INSTRUCTION;  // 进入游戏说明
		case 27://esc的ascii=27
			isRun = false;  // 退出游戏
			return HOME_PAGE;
		}
	}
}